package com.zhy.listener;

import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

/**
 * 事件监听器
 * ApplicationListener里的泛型是指定监听的事件类型
 * Created by zhy on 2017/4/27.
 */
@Component
public class DemoListener implements ApplicationListener<DemoEvent> {


    /**
     * 对消息进行接收处理
     * @param demoEvent
     */
    public void onApplicationEvent(DemoEvent demoEvent) {
        String msg = demoEvent.getMsg();
        System.out.println("我(bean-demoListener)接收到了bean-demoPublisher发布的消息 ：" + msg);
    }
}
